#include <iostream>
#include <string>
#include <algorithm>
#include <stack>
using namespace std;

bool valid_parenthesis_string(string s){
    bool res = true;
    stack<int> lstack;
    stack<int> star;
    for (unsigned int i = 0; i < s.size(); i++) {
        if (s[i] == '(')
            lstack.push(i);
        else if (s[i] == '*')
            star.push(i);
        else {
            if (!lstack.empty()) {
                lstack.pop();
            } else if (!star.empty()) {
                star.pop();
            } else {
                res = false;
                break;
            }
        }
    }
    while (!lstack.empty()) {
        if (!star.empty()) {
            int l = lstack.top();
            int s = star.top();
            if (l < s) {
                lstack.pop();
                star.pop();
            } else {
                res = false;
                break;
            }
        } else {
            res = false;
            break;
        }
    }
    return res;

}

int main() {
    string s;
    cin >> s;
    string res = valid_parenthesis_string(s) ? "True" : "NO";
    cout << res << endl;
    return 0;
}